﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace War
	{
	class Deck
		{
		const int TOTAL_CARDS = 52;
		Random rnd;
		private Card[] deck;
		private int cardsLeft;
		public Deck(Random rand)
		{
		rnd = rand;
		}
		public int CardsLeft
			{
			get { return cardsLeft; }
			private set { cardsLeft = value; }
			}
		public void NewDeck()
			{
			deck = new Card[TOTAL_CARDS];
			int iSuit, iValue, idx = 0;
			Card newCard;
			for (iSuit = 3; iSuit < 7; iSuit++)
				{
				for (iValue = 2; iValue < 15; iValue++)
					{
					newCard = new Card();
					newCard.Value = iValue;
					newCard.Suit = ((char)iSuit).ToString();
					deck[idx] = newCard;
					idx++;
					}
				}
			cardsLeft = TOTAL_CARDS;
			}
		public Card DealCard()
			{
			int position = rnd.Next(0, cardsLeft);
			Card returnCard;
			returnCard = deck[position];
			cardsLeft--;
			deck[position] = deck[cardsLeft];
			return returnCard;
			}

		}//Class
	}//NameSpace
